package com.muyu.danmo.controller;

import com.muyu.common.core.domain.Result;
import com.muyu.common.core.utils.poi.ExcelUtil;
import com.muyu.common.core.web.controller.BaseController;
import com.muyu.common.core.web.page.TableDataInfo;
import com.muyu.common.log.annotation.Log;
import com.muyu.common.log.enums.BusinessType;
import com.muyu.common.security.annotation.RequiresPermissions;
import com.muyu.danmo.domain.DanmoMountImagesType;
import com.muyu.danmo.service.IDanmoMountImagesTypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;


/**
 * 装裱图片类型Controller
 *
 * @author ruoyi
 * @date 2024-10-14
 */
@RestController
@RequestMapping("/mountType")
public class DanmoMountImagesTypeController extends BaseController
{
    @Autowired
    private IDanmoMountImagesTypeService danmoMountImagesTypeService;

    /**
     * 查询装裱图片类型列表
     */
    @RequiresPermissions("system:type:list")
    @GetMapping("/list")
    public Result<TableDataInfo<DanmoMountImagesType>> list(DanmoMountImagesType danmoMountImagesType)
    {
        startPage();
        List<DanmoMountImagesType> list = danmoMountImagesTypeService.selectDanmoMountImagesTypeList(danmoMountImagesType);
        return getDataTable(list);
    }

    /**
     * 导出装裱图片类型列表
     */
    @RequiresPermissions("system:type:export")
    @Log(title = "装裱图片类型", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DanmoMountImagesType danmoMountImagesType)
    {
        List<DanmoMountImagesType> list = danmoMountImagesTypeService.selectDanmoMountImagesTypeList(danmoMountImagesType);
        ExcelUtil<DanmoMountImagesType> util = new ExcelUtil<DanmoMountImagesType>(DanmoMountImagesType.class);
        util.exportExcel(response, list, "装裱图片类型数据");
    }

    /**
     * 获取装裱图片类型详细信息
     */
//    @RequiresPermissions("system:type:query")
    @GetMapping(value = "/{id}")
    public Result getInfo(@PathVariable("id") Long id)
    {
        return success(danmoMountImagesTypeService.selectDanmoMountImagesTypeById(id));
    }

    /**
     * 新增装裱图片类型
     */
//    @RequiresPermissions("system:type:add")
    @Log(title = "装裱图片类型", businessType = BusinessType.INSERT)
    @PostMapping
    public Result add(@RequestBody DanmoMountImagesType danmoMountImagesType)
    {
        return toAjax(danmoMountImagesTypeService.insertDanmoMountImagesType(danmoMountImagesType));
    }

    /**
     * 修改装裱图片类型
     */
//    @RequiresPermissions("system:type:edit")
    @Log(title = "装裱图片类型", businessType = BusinessType.UPDATE)
    @PutMapping
    public Result edit(@RequestBody DanmoMountImagesType danmoMountImagesType)
    {
        return toAjax(danmoMountImagesTypeService.updateDanmoMountImagesType(danmoMountImagesType));
    }

    /**
     * 删除装裱图片类型
     */
//    @RequiresPermissions("system:type:remove")
    @Log(title = "装裱图片类型", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public Result remove(@PathVariable Long[] ids)
    {
        return toAjax(danmoMountImagesTypeService.deleteDanmoMountImagesTypeByIds(ids));
    }
}
